package com.gavindon.plugin.task

import org.apache.tools.ant.types.ArchiveFileSet
import org.gradle.api.file.FileTree
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

/**
 * description: 注意自定义的task需要使用open来修饰 因为kotlin创建的类默认为final
 * Created by liNan on  2021/6/28 14:48
 */
open class CopyTask : Copy() {

    /**
     * 复制单个文件
     */
    @TaskAction
    fun copyFile() {
        val from1 = "${project.rootDir}/test.txt"
        val from2 = "${project.rootDir}/test1.txt"
        val to = "${project.projectDir}"
        from(from1, from2)
        into(to)
        rename {
            "$it-copy.txt"
        }

    }

    /**
     * 复制目录
     */
    @TaskAction
    fun copyFiles() {
        val fromSrc = "${project.rootDir}/copyTest"
        val toDes = "${project.rootDir}/toArc"
        from(fromSrc)
//        include("*.py")
//        exclude("*.py")
        filter { "**/copy1.txt" }
        into(toDes)

    }

}